Conversation
Co-Authored-By: Thiago Araujo <thd.araujo@gmail.com>
Co-Authored-By: Thiago Araujo <thd.araujo@gmail.com>
Profiling laoding faker showed that by autoloading OpenSSL, we could improve Faker's loading time by about 17%. A lot of the time is spent on set_default_paths. Given that OpenSSL is only used in a very limited way and only by 3 generators, this would speed up the library for most users. Co-Authored-By: Thiago Araujo <thd.araujo@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3186
This work has been co-authored with @thdaraujo
The following generators require OpenSSL:
The profiler screenshots show that loading faker spent about 9% of the samples doing that:
vernier run -- ruby -e 'load("/Users/stefannibrasil/projects/faker/lib/faker.rb")'Call tree:

Stack chart:

benchmark
CI:
took 125.20560900000532ms to loadWe tried requiring 'openssl/digest' only but we still needed to require 'openssl' somewhere else.
The next step was testing autoloading OpenSSL.
Autoload OpenSSL
CI:
took 80.12221799998542ms to loadresults
ruby load.rb ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin24] Warming up -------------------------------------- require openssl 1.000 i/100ms autoload openssl 1.000 i/100ms Calculating ------------------------------------- require openssl 10.485 (± 0.0%) i/s (95.37 ms/i) - 53.000 in 5.057875s autoload openssl 12.429 (± 0.0%) i/s (80.46 ms/i) - 63.000 in 5.072235s Comparison: require openssl: 10.5 i/s autoload openssl: 12.4 i/s - 1.19x fasterAutoloading OpenSSL is ~19% faster 🚀
Call tree:

Stack Chart:
